package com.wanghua.mall.ware.service.impl;

import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wanghua.common.utils.PageUtils;
import com.wanghua.common.utils.Query;

import com.wanghua.mall.ware.dao.WareOrderTaskDao;
import com.wanghua.mall.ware.entity.WareOrderTaskEntity;
import com.wanghua.mall.ware.service.WareOrderTaskService;


@Service
public class WareOrderTaskServiceImpl extends ServiceImpl<WareOrderTaskDao, WareOrderTaskEntity> implements WareOrderTaskService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<WareOrderTaskEntity> page = this.page(
                new Query<WareOrderTaskEntity>().getPage(params),
                new QueryWrapper<>()
        );

        return new PageUtils(page);
    }

    /**
     * 查询最新库存状态，防止重复解锁库存
     *
     * @param orderNo
     * @return
     */
    @Override
    public WareOrderTaskEntity getTaskByOrderNo(String orderNo) {
        return baseMapper.selectOne(new QueryWrapper<WareOrderTaskEntity>().eq("order_no", orderNo));
    }

}